#include "gnum.h"
#include <iostream.h>

int main()
{
	GCodeNumber number;
	unsigned char uc;

	cout << "[" << number.getSignificand() << ", " << int(number.getExponent()) << "]." << endl;
	for (uc = 1; uc <= 5; uc++) {
		if (number.addDigit(uc)) {
			cout << "addDigit(" << int(uc) << ") OK: ";
			cout << "[" << number.getSignificand() << ", " << int(number.getExponent()) << "]." << endl;
		}
	}
	cout << "leading     = " << (int)number.getLeading() << endl;
	cout << "trailing    = " << (int)number.getTrailing() << endl;
	if (number.isFloat() == true)
		cout << "Number is float."<< endl;
	number.beginFraction();
	cout << "beginFraction(): ";
	cout << "[" << number.getSignificand() << ", " << int(number.getExponent()) << "]." << endl;
	cout << "leading     = " << (int)number.getLeading() << endl;
	cout << "trailing    = " << (int)number.getTrailing() << endl;
	if (number.isFloat() == true)
		cout << "Number is float."<< endl;
	if (number.isNegative() == true)
		cout << "Number is negative."<< endl;
	number.negate();
	cout << "negate(): ";
	cout << "[" << number.getSignificand() << ", " << int(number.getExponent()) << "]." << endl;
	if (number.isNegative() == true)
		cout << "Number is negative."<< endl;
	if (number.addDigit(6)) {
		cout << "addDigit(6) OK: ";
		cout << "[" << number.getSignificand() << ", " << int(number.getExponent()) << "]." << endl;
	}
	cout << "leading     = " << (int)number.getLeading() << endl;
	cout << "trailing    = " << (int)number.getTrailing() << endl;
	long int int32 = number;
	cout << "\tSave as: " << int32 << endl;
	GCodeNumber number2(int32);
	cout << "\tReload: [" << number2.getSignificand() << ", " << int(number2.getExponent()) << "]." << endl;
	cout << "leading     = " << (int)number2.getLeading() << endl;
	cout << "trailing    = " << (int)number2.getTrailing() << endl;
	for (uc = 7; uc <= 9; uc++) {
		if (number2.addDigit(uc)) {
			cout << "addDigit(" << int(uc) << ") OK: ";
			cout << "[" << number2.getSignificand() << ", " << int(number2.getExponent()) << "]." << endl;
			cout << "leading     = " << (int)number2.getLeading() << endl;
			cout << "trailing    = " << (int)number2.getTrailing() << endl;
		}
	}
	return 0;
}
